: The HTML Select element

您所在的位置:网站首页 element selection翻译 : The HTML Select element

: The HTML Select element

2024-07-07 15:55| 来源: 网络整理| 查看: 265

The above example shows typical usage. It is given an id attribute to enable it to be associated with a for accessibility purposes, as well as a name attribute to represent the name of the associated data point submitted to the server. Each menu option is defined by an element nested inside the .

Each element should have a value attribute containing the data value to submit to the server when that option is selected. If no value attribute is included, the value defaults to the text contained inside the element. You can include a selected attribute on an element to make it selected by default when the page first loads.

A element is represented in JavaScript by an HTMLSelectElement object, and this object has a value property which contains the value of the selected .

The element has some unique attributes you can use to control it, such as multiple to specify whether multiple options can be selected, and size to specify how many options should be shown at once. It also accepts most of the general form input attributes such as required, disabled, autofocus, etc.

You can further nest elements inside elements to create separate groups of options inside the dropdown. You can also include elements to create separators that add visual breaks between options.

For further examples, see The native form widgets: Drop-down content.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3